package com.example.mybatis;

import com.example.mybatis.domain.Food;
import com.example.mybatis.mapper.FoodMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class FoodMybatis {
    @Autowired
    FoodMapper foodMapper;
    @Test
    public void testSelectList(){
        List<Food> foods = foodMapper.selectList();
        System.out.println(foods);
    }
    /**
     * @Description: 根据主键id查询一条记录
     * @Author: Ma_XiaoLong
     * @CreateTime: 2024/1/29 17:15
     **/
    //根据主键id查询一条记录
    @Test
    public void testSelectById(){
        Food food = foodMapper.selectById(1l);
        System.out.println("根据id查询到的菜品是："+ food);
    }

    /**
     * @Description: 多条件查询
     * @Author: Ma_XiaoLong
     * @CreateTime: 2024/1/29 17:21
     **/
    //多条件查询
    @Test
    public void testSelectByCondition(){
        Food food = foodMapper.selectByCondition("hotpot","15");
        System.out.println("根据菜品名字和尺寸查询到的菜品是:"+food);

    }
}
